package com.example.monkey.myapplication;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;


public class MainActivity extends ActionBarActivity {

    private TextView textView1;

    private TextView textView2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView1 = (TextView) this.findViewById(R.id.textview1);
        textView2 = (TextView) this.findViewById(R.id.textview2);
        //添加一段html的标志
        String html = "<font color='red'>I Love Android</font><br/>";
        html  +="<font color='#0000ff'><big><i>I Love Android</i></big></font><br/>";
        html = html + "<big><a href='http://www.baidu.com'>百度</a><big> <br/>";
        CharSequence charSequence = Html.fromHtml(html);
        textView1.setText(charSequence);
        //点击的时候产生超链接
        textView1.setMovementMethod(LinkMovementMethod.getInstance());

        String text = "我的URL:http://www.baidu.com\n";
        text = text + "我的email:abcd@126.com\n";
        text = text+"我的电话:+ 86 010-897477389";
        textView2.setText(text);
        textView2.setMovementMethod(LinkMovementMethod.getInstance());
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
